package com.ruan.service;

import com.ruan.dao.ShoppingCartMapper;
import com.ruan.openfeign.GoodsCenterOpenfeign;
import com.ruan.openfeign.UserCenterOpenfeign;
import com.ruan.query.ShoppingCartQuery;
import com.ruan.vo.ShoppingCartVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName:ShoppingCartService
 * @Author:阮昇
 * @Description:
 * @Datetime: 2023/6/20 16:54
 **/
@Service
public class ShoppingCartService {

    @Autowired
    private ShoppingCartMapper shoppingCartMapper;
    @Resource
    private GoodsCenterOpenfeign goodsCenterOpenfeign;
    @Resource
    private UserCenterOpenfeign userCenterOpenfeign;
    public List<ShoppingCartVo> getShoppingCartList(ShoppingCartQuery shoppingCartQuery) {

        List<ShoppingCartVo> shoppingCartVoList = shoppingCartMapper.getShoppingCartList(shoppingCartQuery);

        for(ShoppingCartVo i:shoppingCartVoList){

            i.setGoodsName(goodsCenterOpenfeign.getGoodsById(i.getGoodsId()).getGoodsName());

            i.setGoodsPrize(goodsCenterOpenfeign.getGoodsById(i.getGoodsId()).getGoodsPrize());

            i.setUserName(userCenterOpenfeign.getUserById(i.getUserId()).getUserName());

        }

        return shoppingCartVoList;

    }
}
